#include "Socket.h"


Socket::operator SOCKET() {
	return mSharedPtrSocketHolder->mSocket;
}

Socket::Socket(SOCKET s) 
	// the sharedPointer will destroy the SocketHolder 
	// once all references to it are gone
	// the SocketHolder will then close the socket handle to release the resources
	: mSharedPtrSocketHolder(new SocketHolder(s)) 
{}

Socket::SocketHolder::~SocketHolder() {
	// on destruction of the Holder object, release the SOCKET
	::closesocket(mSocket);
}

Socket::SocketHolder::SocketHolder(SOCKET s) 
	:mSocket(s)
{}

